package com.accloud.common;

import cn.ablecloud.service.BuildConfig;
import com.accloud.utils.LogUtil;
import cz.msebera.android.httpclient.HttpStatus;

public class ACConfiguration {
    public static final String ACCOUNT_SERVICE_NAME = "zc-account";
    public static final int ACCOUNT_SERVICE_VERSION = 1;
    public static int AUTH_TIMEOUT = HttpStatus.SC_MULTIPLE_CHOICES;
    public static final String BIND_SERVICE_NAME = "zc-bind";
    public static final int BIND_SERVICE_VERSION = 1;
    public static final String BLOBSTORE_SERVICE_NAME = "zc-blobstore";
    public static final int BLOBSTORE_SERVICE_VERSION = 1;
    public static int CONNECT_TIMEOUT = 5;
    public static final String FEEDBACK_SERVICE_NAME = "zc-feedback";
    public static final int FEEDBACK_SERVICE_VERSION = 1;
    public static final String KEY_HEAD = "ablecloud_private";
    public static final String KEY_REFRESH_TOKEN = "ablecloud_private_refresh_token";
    public static final String KEY_REFRESH_TOKEN_EXPIRE = "ablecloud_private_fefresh_token_expire";
    public static final String KEY_TOKEN = "ablecloud_private_token";
    public static final String KEY_TOKEN_EXPIRE = "ablecloud_private_token_expire";
    public static final String KEY_USERID = "ablecloud_private_userId";
    private static int MODE = 1;
    private static final String ONLINE_APP_GATEWAY_ADDR_CENTERAL_EUPOPE = "https://euws.ablecloud.cn:9006";
    private static final String ONLINE_APP_GATEWAY_ADDR_CHINA = "https://ws.ablecloud.cn:9006";
    private static final String ONLINE_APP_GATEWAY_ADDR_EAST_CHINA = "https://ecws.ablecloud.cn:9006";
    private static final String ONLINE_APP_GATEWAY_ADDR_NORTH_AMERICA = "https://usws.ablecloud.cn:9006";
    private static final String ONLINE_APP_GATEWAY_ADDR_SOUTHEAST = "https://eaws.ablecloud.cn:9006";
    private static final String ONLINE_ROUTER_ADDR_CENTERAL_EUPOPE = "eurouter.ablecloud.cn";
    private static final String ONLINE_ROUTER_ADDR_CHINA = "router.ablecloud.cn";
    private static final String ONLINE_ROUTER_ADDR_NORTH_AMERICA = "usrouter.ablecloud.cn";
    private static final String ONLINE_ROUTER_ADDR_SOUTHEAST = "earouter.ablecloud.cn";
    public static final String OTA_SERVICE_NAME = "zc-ota";
    public static final int OTA_SERVICE_VERSION = 1;
    public static final String PM25_SERVICE_NAME = "zc-pm25";
    public static final int PM25_SERVICE_VERSION = 1;
    public static final String PRODUCT_SERVICE_NAME = "zc-product";
    public static final int PRODUCT_SERVICE_VERSION = 1;
    public static final String RANKING_SERVICE_NAME = "zc-ranking";
    public static final int RANKING_SERVICE_VERSION = 1;
    public static int READ_TIMEOUT = 5;
    private static int REGIONAL = 0;
    private static String SANDBOX_ROUTER_ADDR = BuildConfig.SANDBOX_ROUTER_HOST;
    public static final String TIMER_SERVICE_NAME = "zc-timer-task";
    public static final int TIMER_SERVICE_VERSION = 1;
    public static final String WAREHOUSE_SERVICE_NAME = "zc-warehouse";
    public static final int WAREHOUSE_SERVICE_VERSION = 1;

    public static void setMode(int mode) {
        MODE = mode;
//        if (mode == 0) {
//            LogUtil.setDebug(true);
//        } else {
//            LogUtil.setDebug(false);
//        }
    }

    public static void setRegional(int regional) {
        REGIONAL = regional;
    }

    public static int getMode() {
        return MODE;
    }

    public static int getRegional() {
        return REGIONAL;
    }

    public static void setRouterAddr(String ROUTER_ADDR) {
        SANDBOX_ROUTER_ADDR = ROUTER_ADDR;
    }

    public static String getRouterAddr() {
        if (getMode() == 0) {
            return "https://" + SANDBOX_ROUTER_ADDR + ":9005";
        }
        if (getRegional() == 4) {
            return "https://eurouter.ablecloud.cn:9005";
        }
        if (getRegional() == 3) {
            return "https://usrouter.ablecloud.cn:9005";
        }
        if (getRegional() == 1) {
            return "https://earouter.ablecloud.cn:9005";
        }
        return "https://router.ablecloud.cn";
    }

    public static String getHttpsRouterAddr() {
        if (getMode() == 0) {
            return "https://" + SANDBOX_ROUTER_ADDR + ":9005";
        }
        if (getRegional() == 4) {
            return "https://eurouter.ablecloud.cn:9005";
        }
        if (getRegional() == 3) {
            return "https://usrouter.ablecloud.cn:9005";
        }
        if (getRegional() == 1) {
            return "https://earouter.ablecloud.cn:9005";
        }
        return "https://router.ablecloud.cn:9005";
    }

    public static String getAppGatewayAddr() {
        if (getMode() == 0) {
            return "https://" + SANDBOX_ROUTER_ADDR + ":9006";
        }
        if (getRegional() == 1) {
            return ONLINE_APP_GATEWAY_ADDR_SOUTHEAST;
        }
        if (getRegional() == 2) {
            return ONLINE_APP_GATEWAY_ADDR_EAST_CHINA;
        }
        if (getRegional() == 3) {
            return ONLINE_APP_GATEWAY_ADDR_NORTH_AMERICA;
        }
        if (getRegional() == 4) {
            return ONLINE_APP_GATEWAY_ADDR_CENTERAL_EUPOPE;
        }
        return ONLINE_APP_GATEWAY_ADDR_CHINA;
    }
}
